<template>
    <div>
        <div>
            <h2>用户登录</h2>
               用户名: <el-input v-model="userName" placeholder="请输入用户名"></el-input>
               密码:<el-input type="password" v-model="password" placeholder="请输入密码"></el-input>
                <el-button type="primary" @click="userLogin()">登录</el-button>
        </div>
    </div>
</template>

<script>

export default {
    data() {
        return {
            userName: '',
            password:''
        }
    },
    methods: {
        userLogin() { 
            this.$axios.post('http://localhost:7000/user/userLogin', { 'userName': this.userName, 'password': this.password }).then(res => {
                if (res.data.code==1) { 
                    this.$router.push( {name: "index"});
                }

            });
        }
    },
    //生命周期 - 创建完成（访问当前this实例）
    created() {
        
    },
    //生命周期 - 挂载完成（访问DOM元素）
    mounted() {
        
    }
}
</script>
<style scoped>
/* @import url(); 引入css类 */

</style>